import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const moduleA = {
  state: {
    userInfo: [
      { userName: 'zwn', age: 22, sex: '男' },
      { userName: 'zjp', age: 23, sex: '女' }
    ],
    count: 0,
    message: '还有一小时'
  },
  getters: {
    getUserName (state) {
      return state.userInfo[0].userName
    }
  },
  mutations: {
    updateUsername (state, content) {
      state.count++
      console.log(content)
    }
  },
  actions: {
    updateUsername (content, payload) {
      setTimeout(() => {
        content.commit('updateUsername')
        console.log(payload)
      }, 1000)
    }
  }
}
export default new Vuex.Store({
  modules: {
    a: moduleA
  }
})
